var sureOrder = {}
$(function () {
    // 选择支付方式交互
    $(".shop-order-payway > ul > .noselectedLi").on("click", function () {
        $(".shop-order-payway > ul > .noselectedLi").removeClass("selectedLi");
        $(this).addClass("selectedLi");
    });
    // 选择收货地址交互
    $(".shop-order-addr .shop-order-addr-rect li .shop-addr-content-nosel").on("click", function () {
        $(".shop-order-addr .shop-order-addr-rect li .shop-addr-content-nosel").removeClass("shop-addr-selected");
        $(this).addClass("shop-addr-selected");
    });

    // 设为默认地址
    $(".shop-order-addr > ul .shop-addr-content-nosel .shop-addr-content-operator > p").on("click", function () {
        $(".shop-order-addr .shop-order-addr-rect li .shop-addr-content-nosel").removeClass("shop-addr-default");
        $(this).parents(".shop-addr-content-nosel").addClass("shop-addr-default");
    });

    // 提交订单
    $(".shop-order-otherInfo .shop-btn-group .shop-btn-submit").on("click", function () {
        sureOrder.verifyAddress()
    });

    // 验证地址是否有效
    sureOrder.verifyAddress = function () {
        if ($(".shop-addr-selected").length < 1) {
            $(".shop-no-address").css("display", "block");
            return false
        }
        return true
    }
    // 新增地址弹窗
    $(".shop-add-order").on("click", function () {
        $(".shop-window").load("../../template/addInvoice.html");
        $(".shop-sure-order-pop-ups").show();
    });

    
    // 新增发票弹窗
    $(".shop-add-order").on("click", function () {
        $(".shop-window").load("../../template/addInvoice.html", null, function () {
            $(".shop-sure-order-pop-ups").show();
            $(".shop-window .shop-header img").on("click", function () {
                $(".shop-sure-order-pop-ups").hide();
            });
        }).addClass("shop-addInvoice");
    });
    // 关闭无地址提示框
    $(".shop-no-address .shop-no-address-in .shop-body button,  .shop-no-address .shop-no-address-in .shop-header img").off("click").on("click", function () {
        $(".shop-no-address").css("display", "none");
    });

});







    // // 添加收货地址弹窗
    // $(".shop-order-addr .shop-addr-content-add").on("click", function () {
    //     $("body").prepend('<div class="pop-ups shop-add-consignee"></div>');
    //     $(".pop-ups").load("../../templates/AddConsignee.html");
    // });

    // // 收货地址信息修改
    // $(".shop-order-addr > ul .shop-addr-content-nosel .shop-addr-content-operator > .shop-addr-modify").on("click", function () {
    //     receiver.windowPop("修改收货地址信息", function (data) {
    //         console.log(data);
    //         receiver.windowShut();
    //     }, function () {
    //         return { name: "李四" }
    //     });
    // });
    // // 选择支付方式交互
    // $(".shop-order-payway > ul > .noselectedLi").on("click", function () {
    //     $(".shop-order-payway > ul > .noselectedLi").removeClass("selectedLi");
    //     $(this).addClass("selectedLi");
    // });、

    // // 选择收货地址交互
    // $(".shop-order-addr .shop-order-addr-rect li .shop-addr-content-nosel").on("click", function () {
    //     $(".shop-order-addr .shop-order-addr-rect li .shop-addr-content-nosel").removeClass("shop-addr-selected");
    //     $(this).addClass("shop-addr-selected");
    // });

    // // 设为默认地址
    // $(".shop-order-addr > ul .shop-addr-content-nosel .shop-addr-content-operator > p").on("click", function () {
    //     $(".shop-order-addr .shop-order-addr-rect li .shop-addr-content-nosel").removeClass("shop-addr-default");
    //     $(this).parents(".shop-addr-content-nosel").addClass("shop-addr-default");
    // });

    // // 提交订单
    // $(".shop-order-otherInfo .shop-btn-group .shop-btn-submit").on("click", function () {
    //     sureOrder.verifyAddress()
    // });




    
    // var sureOrder = {}
    // // 验证地址是否有效
    // sureOrder.verifyAddress = function () {
    //     if ($(".shop-addr-selected").length < 1) {
    //         $(".shop-no-address").css("display", "block");
    //     }
    //     $(".shop-no-address .shop-no-address-in .shop-body button,  .shop-no-address .shop-no-address-in .shop-header img").off("click").on("click", function () {
    //         $(".shop-no-address").css("display", "none");
    //     });
    // }
